* Generates Figure B.6 (Sensitivity with respect to the minimum time required between devaluations)
use "Empirics/AggregateData/Database/output/Database.dta", clear
cd "Empirics/AggregateData/Analysis"
set more off
graph drop _all

*. Locals
local GraphsByEpi=0

*. Where to store results
local outputfolder "../../../Output"
capture mkdir `outputfolder'

*. Set Window length
local windowstart=-4
local windowend=8

*. Minimum # years events need to be apart
local apart=8 // sensitivity

*. Create variables & Declare panel
qui do "Analysis_dofiles/CreateVars.do" `outputfolder'

*. Identify Large Devaluations
gen largeDevaluation = 1 if gER<=-0.20 & acceER<=-0.10 & gRER<=0

* Ensure events are X years apart, where X is given by `apart'
qui do "Analysis_dofiles/Apart.do" `apart' `outputfolder' `windowstart' `windowend' 

* Additional sample adjustments
qui do "Analysis_dofiles/Adjustments.do"

*. Extract list of events in the sample
qui do "Analysis_dofiles/ExtractList.do"

sort id year
*. Create more variables:
qui do "Analysis_dofiles/CreateMoreVars.do"

* Generate Figure B.6 and save
qui do "Analysis_dofiles/Produce_FB6.do" `outputfolder' `GraphsByEpi' `windowstart' `windowend'
graph export "../../../Output/FB6.pdf", replace

cd ../../..
